<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示指令的使用</title>
    <script src="./js/vue@3.5.12.global.js"></script>
    <style>
        .style1{
            width: 200px;
            height: 200px;
            background-color: red;
        }
        .style2{
            width: 300px;
            height: 300px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <div id="app">
        <div :class="style" @click="changeColor"></div>
    </div>
</body>
<script>
    const app = Vue.createApp({
        /*model*/
        data(){
            return {
                style: 'style1'
            }
        },
        /*放函数的地方*/
        methods:{
            /*改变颜色的函数*/
            changeColor(){
                //this.style = 'style2';
                this.style = this.style==='style1'?'style2':'style1';
            }
        }
    })
    app.mount('#app')
</script>
</html>